from flask import Flask
from flask_cors import CORS
from extensions import db, migrate
from routes import api
from models import *
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    db.init_app(app)
    migrate.init_app(app, db)
    CORS(app)

    with app.app_context():
        app.register_blueprint(api)   # 注册蓝图

    return app

app = create_app()

if __name__ == '__main__':
    app.run(debug=True)